<?php

function getfollowstatus($uid, $fuid) {
	global $_SGLOBAL;

	$query = $_SGLOBAL['db']->query("SELECT status FROM ".tname('follow')." WHERE uid='$uid' AND fuid='$fuid' LIMIT 1");
	if($value = $_SGLOBAL['db']->fetch_array($query)) {
		return $value['status'];
	} else {
		return -1;//没有记录
	}
}



function followlist($uid,$uf='',$op){
    global $_SGLOBAL;
    
    $mpurl = 'admincp.php?ac=follow&op='.$op.'&uid='.$uid;
    
    $wheresql=" {$uf}uid='$uid' and status=1";
    
    if(!in_array($perpage, array(20,50,100,1000))) $perpage = 20;
    
    $page = empty($_GET['page'])?1:intval($_GET['page']);
    
    if($page<1) $page = 1;
	$start = ($page-1)*$perpage;
	//检查开始数
	ckstart($start, $perpage);
    
    if($perpage > 100) {
		$count = 1;

	} else {
		$count = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM ".tname('follow')." WHERE $wheresql"), 0);
	}
    
    $list = array();
	$multi = '';
    
    if($count) {
    
        $nuf=($uf=='')?'f':'';
    
        $query = $_SGLOBAL['db']->query("SELECT {$nuf}uid as uid,{$nuf}username as username,remarks,dateline FROM ".tname('follow')." WHERE $wheresql order by dateline desc LIMIT $start,$perpage");
    
		while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        
            $value['space']=getspace($value['uid']);
            
			$list[] = $value;
            
		}
		$multi = multi($count, $perpage, $page, $mpurl);
        
    }
    
    if($perpage > 100) {
		$count = count($list);
	}

    return array($list,$count,$multi);
}



?>